home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / inventor / noodle / Interface.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  5.9 KB  |  183 lines

  1. /*
  2.  * Copyright (C) 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. /*
  18.  |   Description:
  19.  |    This file defines the Interface class. It creates and manages
  20.  |      the pulldown menus for noodle.
  21.  |
  22.  |   Author(s): Paul Isaacs
  23.  |
  24.  */
  25.  
  26. #ifndef  _INTERFACE_
  27. #define  _INTERFACE_
  28.  
  29. #include <Xm/Xm.h>
  30.  
  31. #include <Inventor/SbLinear.h>
  32. #include <Inventor/SoLists.h>
  33. #include <Inventor/nodes/SoSelection.h>
  34.  
  35. extern class GeneralizedCylinder;
  36. extern class WorldInfo;
  37. extern class SoXtViewer;
  38. extern class NoodleTextureGizmo;
  39. extern class NoodleSurfaceGizmo;
  40.  
  41. class Interface;
  42.  
  43. struct NoodleButtonInfo {
  44.     char *name;
  45.     int   id;
  46.     int   buttonType;  // PUSH, TOGGLE, RADIO
  47.     SbBool isOn;       // relevant for toggles.
  48.     char *accelerator; // e.g. "Alt <Key> p"
  49.     char *accelText;   // text that appears in the menu item
  50. };
  51.  
  52. struct NoodleMenuItem {
  53.     int    id;
  54.     Widget widget;
  55.     Interface *ownerInterface;
  56. };
  57.  
  58. struct NoodleMenu {
  59.     char  *name;
  60.     int    id;
  61.     struct NoodleButtonInfo *subMenu;
  62.     int    subItemCount;
  63. };
  64.  
  65. //////////////////////////////////////////////////////////////////////////////
  66. //
  67. //  Class: Interface
  68. //
  69. //////////////////////////////////////////////////////////////////////////////
  70.  
  71. class Interface {
  72.     
  73.   public:
  74.  
  75.     Interface();
  76.     ~Interface();
  77.  
  78.     // Builds widgets for the top bar menus
  79.     Widget build( Widget parentWidget );
  80.  
  81.     void       setWorldInfo( WorldInfo *newWorldInfo );
  82.     WorldInfo *getWorldInfo() { return worldInfo; }
  83.  
  84.     void       setMainViewer( SoXtViewer *newMainViewer ) 
  85.                   { mainViewer = newMainViewer; }
  86.     SoXtViewer *getMainViewer() { return mainViewer; }
  87.  
  88.     void setProfileViewer( SoXtViewer *newV ) { profileViewer = newV; }
  89.     void setSectionViewer( SoXtViewer *newV ) { sectionViewer = newV; }
  90.     void setSpineViewer(   SoXtViewer *newV ) { spineViewer = newV; }
  91.     void setTwistViewer(   SoXtViewer *newV ) { twistViewer = newV; }
  92.  
  93.     void setProfileCloseButton( Widget newW ) { closeProfileButton = newW; }
  94.     void setSectionCloseButton( Widget newW ) { closeSectionButton = newW; }
  95.     void setSpineCloseButton(   Widget newW ) { closeSpineButton = newW; }
  96.     void setTwistCloseButton(   Widget newW ) { closeTwistButton = newW; }
  97.  
  98.     SbColor getBackgroundColor() { return bgColor; }
  99.     void    setBackgroundColor( SbColor newColor ) { bgColor = newColor; }
  100.  
  101.     // Reads the scene given by filename and puts the results into worldInfo.
  102.     // Returns pointer to top of scene graph.
  103.     // If filename is NULL, uses name already found in worldInfo.
  104.     // If filename and worldInfo are both NULL, it is an error.
  105.     SoSeparator *readScene( char *newFileName = NULL, SbBool okIfNoName =FALSE);
  106.  
  107.     // Writes the scene contained in worldInfo.
  108.     // If asVanilla==FALSE, uses special GeneralizedCylinder class in the file. 
  109.     // If asVanilla==TRUE, uses only standard Inventor nodes.
  110.     // If filename is NULL, uses name already found in worldInfo.
  111.     // If filename and worldInfo are both NULL, it is an error.
  112.     void writeToFile( SbBool asVanilla, char *newFileName = NULL );
  113.  
  114.     // Sets info in the interface to reflect contents.
  115.     void setPrimarySelection( GeneralizedCylinder *g );
  116.  
  117.   protected:
  118.  
  119.     // Callback added to WorldInfo's selection node to invoke
  120.     // setPrimarySelection() on the new selection.
  121.     static void selectionCB( void *, SoPath *);
  122.  
  123.     WorldInfo  *worldInfo;
  124.  
  125.     // Processes events for the top bar menus
  126.     static void processTopbarEvent(Widget, NoodleMenuItem *, 
  127.                    XmAnyCallbackStruct *);
  128.  
  129.     // These get done in response to events in the pull down menu.
  130.     void fileNewEvent();
  131.     void fileOpenEvent();
  132.     void fileSaveEvent();
  133.     void fileSaveAsEvent();
  134.     void fileSaveVanillaEvent();
  135.     void fileQuitEvent();
  136.  
  137.     // These build dialogs and/or call up showcase to give info.
  138.     void createOkayCancelDialog(Widget, XtCallbackProc,char *,char *,char *);
  139.     void showAboutDialog();
  140.     void showFileSelectionDialog( XtCallbackProc okCB );
  141.  
  142.     // These callbacks from the dialog boxes cause other actions to be taken.
  143.     static void destroyDialogCB(Widget dialog, void *, void *);
  144.  
  145.     // Callback functions relating to the FILE menu.
  146.     static void newSceneCB(Widget, void *, void *);
  147.     static void openSceneCB(Widget, void *, void *);
  148.     static void readFromFileCB(Widget, void *,
  149.                    XmFileSelectionBoxCallbackStruct *);
  150.     static void writeToFileCB(Widget, void *,
  151.                    XmFileSelectionBoxCallbackStruct *);
  152.     static void writeToVanillaFileCB(Widget, void *,
  153.                    XmFileSelectionBoxCallbackStruct *);
  154.     static void quitProgramCB(Widget, void *, void *);
  155.  
  156.   private:
  157.  
  158.     void setRenderStyleRadioButtons( 
  159.                 GeneralizedCylinder::RenderShapeType shapeType );
  160.     void setManipTypeRadioButtons( const SoType &manipType );
  161.  
  162.     SbColor            bgColor;
  163.     SoXtViewer    *mainViewer; // The viewer used to display the scene.
  164.  
  165.     Widget mgrWidget;
  166.     NoodleMenuItem *menuItems;
  167.  
  168.     NoodleTextureGizmo *myTextureGizmo;
  169.     NoodleSurfaceGizmo *mySurfaceGizmo;
  170.  
  171.     SoXtViewer *profileViewer;
  172.     SoXtViewer *sectionViewer;
  173.     SoXtViewer *spineViewer;
  174.     SoXtViewer *twistViewer;
  175.  
  176.     Widget closeProfileButton;
  177.     Widget closeSectionButton;
  178.     Widget closeSpineButton;
  179.     Widget closeTwistButton;
  180. };
  181.  
  182. #endif /* _INTERFACE_ */
  183.